;
; DZ80 configuration file for pacman.bin
;
c 0000-37ff    ; Mark everything as code to start with

; Memory map from http://www.arcaderestoration.com/memorymap/3302/Galaxian.aspx
;l 4000 WorkRAM
l 40C0 CmdQueue
l 4080 QueueTail
l 4082 QueueHead
l 5000 VideoRAM
l 5800 ObjRAM
l 6000 SW0
l 6800 SW1    ; SW1 on read, sound reset BG 1 on write (but not written except on init)
l 7000 DIPSW
l 7001 NMI_ON
l 7004 STARS_ON
l 7006 H_FLIP
l 7007 V_FLIP
l 7800 Watchdog   ; Watchdog on read, EFFECT_FREQ on write
# 0000
# 0000 Some equates. There are more at the end of the file.
# 0000
;p 0000 WorkRAM	equ	4000h
p 0000 EFFECT_FREQ	equ	7800h
p 0000 SOUND_CTL	equ	6800h
p 0000 OUTPUT_CTL	equ	6000h

l 0000 RST_00_RESET
! 0001 Disable NMI
b 0007-0007
l 0008 RST_08_FillBbytes
l 000C doRET
l 000d X000d
l 0010 RST_10_ByteArrayA
# 0018 Access an array of words by the index in B
# 0018 Input: HL = table address, output: HL = content
# 0018 Trashes DE, A, flags
l 0018 RST_18_WordArrayB
! 001A ByteArrayA
; RST 20h is followed by an undefined number of addresses
l 0020 RST_20_JumpTable
! 0022 ByteArrayA
; RST 28h is followed by 2 bytes
# 0028 Read the two next bytes from the return address and store them
# 0028 in a pointer indicated in X4080 (circular buffer from xxC0 to xxFF)
l 0028 RST_28_EnqueueCmd
; RST 30h is followed by 3 bytes
# 0030 In a strided table of 16x3 bytes starting at X4090, find a zero
# 0030 in the first element and copy 3 bytes from the return address.
l 0030 RST_30_Copy3ToBlank
l 0038 RST_38_
# 005A Copy 3 bytes from the return address, to (DE) and skip them
# 005A before returning.
l 005A Copy3
l 005D Copy3_loop
b 0064-0065
l 0066 NMI
l 008E NMIHandler
b 0069-008D


y 00AB EFFECT_FREQ

y 00BC 001Ch

y 0217 EFFECT_FREQ
y 0221 EFFECT_FREQ

y 0238 0401h
! 025B *2
! 025C *4
! 025D *5
! 025E +1
! 025F (X408b) = (X408b)*5 + 1
! 0262 *2
! 0263 *3
! 0264 *6
! 0265 *12
! 0266 *13
! 0267 +1
! 0268 (X408c) = (X408c)*13 + 1
b 026A-0271
! 0290 Jump table index
! 0291 ?? Unused?
! 0292 ?? Unused?
! 0296 Push return address
! 0297 RST20_JumpTable
! 0298 Inc (X4204)
! 029A Inc (X4203)
! 029C Inc (X4202)
! 029E Inc (X41d1)
! 02A0 Clr (X41d2,X41d3,X41d4)
! 02A6 Inc (X4206)
! 02A8 Inc (X4207)
! 02AA Inc (X4208)
a 0298-02AB
! 02B4 RST28_EnqueueCmd
b 02B5-02B6
! 0418 RST20_JumpTable
a 0419-0420
! 0424 RST20_JumpTable
a 0425-0428
! 0429 RST28_EnqueueCmd
b 042A-042B
! 042A ClrScr
! 042B Full
! 042C RST28_EnqueueCmd
b 042D-042E
! 042F RST28_EnqueueCmd
b 0430-0431
! 0432 RST28_EnqueueCmd
b 0433-0434
! 0435 RST28_EnqueueCmd
b 0436-0437
! 0438 RST28_EnqueueCmd
b 0439-043A
! 043B RST28_EnqueueCmd
b 043C-043D
! 043E RST28_EnqueueCmd
b 043F-0440
! 045E RST20_JumpTable
a 045F-04A6
! 04A7 RST28_EnqueueCmd
b 04A8-04A9
! 04A8 ClrScr
! 04A9 Omit1stColumn
! 04AA RST28_EnqueueCmd
b 04AB-04AC
! 04AD RST28_EnqueueCmd
b 04AE-04AF
! 04B0 RST28_EnqueueCmd
b 04B1-04B2
! 0520 RST28_EnqueueCmd
b 0521-0522
! 0531 RST28_EnqueueCmd
b 0532-0533
! 0534 RST28_EnqueueCmd
b 0535-0536
! 0537 RST28_EnqueueCmd
b 0538-0539
! 053A RST28_EnqueueCmd
b 053B-053C
y 0551 0020h
! 05D2 RST30_Copy3ToBlank
b 05D3-05D5
! 05E5 RST30_Copy3ToBlank
b 05E6-05E8
! 0602 RST18_WordArrayB

y 0610 001Eh

! 062A RST20_JumpTable
a 062B-0634
! 0638 RST28_EnqueueCmd
b 0639-063A
! 0639 ClrScr
! 063A Omit1stColumn
! 063B RST28_EnqueueCmd
b 063C-063D
! 063E RST28_EnqueueCmd
b 063F-0640
! 0641 RST28_EnqueueCmd
b 0642-0643
! 0644 RST28_EnqueueCmd
b 0645-0646
! 0656 RST28_EnqueueCmd
b 0657-0658
! 0659 RST28_EnqueueCmd
b 065A-065B
! 06B1 RST28_EnqueueCmd
b 06B2-06B3
! 06B2 ClrScr
! 06B3 Omit1stColumn
! 06B4 RST28_EnqueueCmd
b 06B5-06B6
! 06B7 RST28_EnqueueCmd
b 06B8-06B9
! 06BA RST28_EnqueueCmd
b 06BB-06BC
! 06BD RST28_EnqueueCmd
b 06BE-06BF
! 06C0 RST28_EnqueueCmd
b 06C1-06C2
! 06C3 RST28_EnqueueCmd
b 06C4-06C5
! 06C6 RST28_EnqueueCmd
b 06C7-06C8
! 06C9 RST28_EnqueueCmd
b 06CA-06CB
b 06DA-06DB
! 06DC RST30_Copy3ToBlank
b 06DD-06DF

a 06FF-074A

b 07D3-0850

y 0855 001Ch
y 085A 000Ch
y 0862 000Ch
y 086A 000Ch
y 0872 000Eh
y 087B 0003h
y 08CD 002Eh

b 0880-08B5
w 089E-08AF
! 08BC RST08_FillBbytes
! 08E2 RST28_EnqueueCmd
b 08E3-08E4
! 08E5 RST28_EnqueueCmd
b 08E6-08E7
! 08E8 RST28_EnqueueCmd
b 08E9-08EA
! 08EB RST28_EnqueueCmd
b 08EC-08ED
! 08EE RST28_EnqueueCmd
b 08EF-08F0
! 08F1 RST28_EnqueueCmd
b 08F2-08F3
! 08F4 RST30_Copy3ToBlank
b 08F5-08F7
! 08F8 RST30_Copy3ToBlank
b 08F9-08FB

! 0922 RST28_EnqueueCmd
b 0923-0924

! 0984 RST28_EnqueueCmd
b 0985-0986
! 0987 RST30_Copy3ToBlank
b 0988-098A

! 09A3 RST28_EnqueueCmd
b 09A4-09A5
! 09A6 RST30_Copy3ToBlank
b 09A7-09A9

! 09D6 RST28_EnqueueCmd
b 09D7-09D8
! 09D7 ClrScr
! 09D8 Omit1stColumn
! 09D9 RST28_EnqueueCmd
b 09DA-09DB
! 09DC RST28_EnqueueCmd
b 09DD-09DE
! 09DF RST28_EnqueueCmd
b 09E0-09E1
! 09E2 RST28_EnqueueCmd
b 09E3-09E4
! 09E5 RST28_EnqueueCmd
b 09E6-09E7
! 09E8 RST28_EnqueueCmd
b 09E9-09EA
! 09EB RST28_EnqueueCmd
b 09EC-09ED
! 09EE RST28_EnqueueCmd
b 09EF-09F0
! 09F1 RST28_EnqueueCmd
b 09F2-09F3
! 09F4 RST28_EnqueueCmd
b 09F5-09F6
! 09FE RST28_EnqueueCmd
b 09FF-0A00
! 0A01 RST28_EnqueueCmd
b 0A02-0A03
! 0A04 RST30_Copy3ToBlank
b 0A05-0A07

! 0A0E RST30_Copy3ToBlank
b 0A0F-0A11

! 0A31 RST30_Copy3ToBlank
b 0A32-0A34

! 0A48 RST30_Copy3ToBlank
b 0A49-0A4B
y 0A4D 0000h

! 0A67 RST28_EnqueueCmd
b 0A68-0A69
! 0A68 ClrScr
! 0A69 Omit1stColumn
! 0A6A RST28_EnqueueCmd
b 0A6B-0A6C
! 0A6D RST28_EnqueueCmd
b 0A6E-0A6F
! 0A70 RST28_EnqueueCmd
b 0A71-0A72
! 0A73 RST28_EnqueueCmd
b 0A74-0A75
! 0A76 RST28_EnqueueCmd
b 0A77-0A78
! 0A79 RST28_EnqueueCmd
b 0A7A-0A7B
! 0A7C RST30_Copy3ToBlank
b 0A7D-0A7F

! 0AA6 RST20_JumpTable
a 0AA7-0AD0

! 0AEA RST08_FillBbytes

y 0B33 0100h

! 0F60 ByteArrayA

! 0F6E RST30_Copy3ToBlank
b 0F6F-0F71

b 0F73-0FB1
y 0FB7 0000h
! 0FBD RST28_EnqueueCmd
b 0FBE-0FBF
! 0FC5 RST28_EnqueueCmd
b 0FC6-0FC7

! 1049 RST20_JumpTable
a 104A-104F

! 1053 RST20_JumpTable
a 1054-1059

! 105D RST20_JumpTable
a 105E-1065

! 1069 RST20_JumpTable
a 106A-1071

! 1078 ??
y 1079 8064h

! 10D0 ??
y 10D1 8064h

! 1114 ??
y 1115 8064h

! 1181 ??
y 1182 8064h

! 11EA RST20_JumpTable
a 11EB-11F0

y 1219 0000h

! 121E RST30_Copy3ToBlank
b 121F-1221

! 124A RST20_JumpTable
a 124B-126C

y 1275 0078h
y 1282 0000h
y 128A 00B4h
y 12A9 00C3h
y 12B1 00D2h
y 12B9 00E1h
y 12C1 00F0h
y 12C9 00FFh
y 12D1 010Eh
y 12D9 011Dh
y 12E1 012Ch
y 12E9 013Bh
y 12F6 0159h
y 1308 01B8h

y 1390 0000h

y 13A6 0000h

! 14B1 Push return address
! 14B5 RST20_JumpTable
a 14B6-14BD

! 195C ??
y 195D 8094h

! 1976 RST30_Copy3ToBlank
b 1977-1979

! 19F7 RST28_EnqueueCmd
b 19F8-19F9

! 1BBD RST28_EnqueueCmd
b 1BBE-1BBF

! 1BCE RST28_EnqueueCmd
b 1BCF-1BD0

! 1C94 RST28_EnqueueCmd
b 1C95-1C96

! 1CA5 RST28_EnqueueCmd
b 1CA6-1CA7

! 1D6B RST28_EnqueueCmd
b 1D6C-1D6D

! 1D7C RST28_EnqueueCmd
b 1D7D-1D7E

! 1E42 RST28_EnqueueCmd
b 1E43-1E44

! 1E53 RST28_EnqueueCmd
b 1E54-1E55

! 1ECB RST18_WordArrayB

! 1EF2 RST18_WordArrayB

! 1F19 RST18_WordArrayB

! 1F40 RST18_WordArrayB

y 1FA8 0400h

! 205D RST20_JumpTable
a 205E-206B

! 20BB RST30_Copy3ToBlank
b 20BC-20BE

! 20E7 RST30_Copy3ToBlank
b 20E8-20EA

! 20F7 RST20_JumpTable
a 20F8-2113

! 2127 RST30_Copy3ToBlank
b 2128-212A

! 21B0 RST30_Copy3ToBlank
b 21B1-21B3

! 21CB RST30_Copy3ToBlank
b 21CC-21CE

! 21D2 RST30_Copy3ToBlank
b 21D3-21D5

! 21E6 RST20_JumpTable
a 21E7-21F2

! 2223 RST30_Copy3ToBlank
b 2224-2226

! 224E RST30_Copy3ToBlank
b 224F-2251

# 2257 Continued from RST 00h (RESET)
l 2257 ResetCont
y 2258 SOUND_CTL
! 225A Clear 8 bytes
y 2262 OUTPUT_CTL
! 2264 Clear 8 bytes
! 226E Clear 8 bytes

;y 2276 WorkRAM
! 2278 Clear 400h = 1024 bytes
! 227E Clear RAM
! 2287 Init 400h = 1024 bytes
! 228C Fill with 40h
! 229B Clear 100h = 256 bytes
y 22A3 EFFECT_FREQ
! 22A5 Upright, right-side-up
! 22CC Clear 3BEh = 958 bytes

! 22CE RST08_FillBbytes
! 22CF RST08_FillBbytes
! 22D0 RST08_FillBbytes
! 22D1 RST08_FillBbytes

! 22D7 RST08_FillBbytes
! 22EC Fill queue with 0FFh
! 22EE Length of queue in bytes
! 22F0 RST08_FillBbytes
# 22F1 Command queue loop
l 22F1 CmdLoop
! 22F1 Enable NMI
! 22FC Grab command in A
! 22FE Ignore if bit 7 set
! 2301 Clear command in queue (it's still in A)
! 2304 Grab parameter in B
! 2305 Clear parameter in queue (it's still in B)
! 230A Wrap around to start of buffer
! 230C Update queue head
! 2312 Push return address

! 2313 RST20_JumpTable
a 2314-2353
! 2314 Cmd 00h: Clear Screen. 0: full, 1: omit 1st column
! 2316 Cmd 01h:
! 2318 Cmd 02h:
! 231A Cmd 03h:
! 231C Cmd 04h:
! 231E Cmd 05h:
! 2320 Cmd 06h:
! 2322 Cmd 07h:
! 2324 Cmd 08h:
! 2326 Cmd 09h:
! 2328 Cmd 0Ah:
! 232A Cmd 0Bh:
! 232C Cmd 0Ch:
! 232E Cmd 0Dh:
! 2330 Cmd 0Eh:
! 2332 Cmd 0Fh:
! 2334 Cmd 10h:
! 2336 Cmd 11h:
! 2338 Cmd 12h:
! 233A Cmd 13h:
! 233C Cmd 14h:
! 233E Cmd 15h:
! 2340 Cmd 16h:
! 2342 Cmd 17h:
! 2344 Cmd 18h:
! 2346 Cmd 19h:
! 2348 Cmd 1Ah:
! 234A Cmd 1Bh:
! 234C Cmd 1Ch:
! 234E Cmd 1Dh:
! 2350 Cmd 1Eh:
! 2352 Cmd 1Fh:


# 2359 Input: B=0: full clear, B=1: partial clear
l 2359 Cmd_ClrScr
! 235A RST20_JumpTable
a 235B-235E
# 235F Clears all screen
l 235F ClrAll
! 2361 0400h=1024 bytes
y 2362 0004h
! 2367 RST08_FillBbytes
# 236C Clears partial screen
l 236C JpPartialClear

! 236F ?? Unused?
b 236F-2370
! 2371 ?? Unused?
y 2372 8004h
! 2374 RST08_FillBbytes
! 2374 ?? Unused?

! 239D ?? (A3E0 = 41952 = -23584)
y 239E 0A3E0h

! 243D RST08_FillBbytes

! 2442 RST08_FillBbytes

b 246C-248B

y 24C6 8064h
y 24CC 807Ch
y 24D2 907Ch
y 24D8 707Ch
y 24DE 80C4h
y 24E4 2E2Ch
y 24ED 2E2Fh
y 24F6 302Fh
y 24FF 2E2Fh
y 2508 2E38h
y 2511 0100h
y 251A 0001h
y 2523 00FFh
y 252C 00FFh
y 2535 0100h
y 253E 0102h
y 2547 0303h
y 2558 0000h
y 255F 0094h
y 256E 1E32h
y 2589 0100h

! 25B0 RST08_FillBbytes
! 25B4 TODO: Appears to be a value, but it could be an address.
y 25B5 0894h
y 25BB 1F32h

y 25C5 0000h

! 2632 ByteArrayA

! 263E RST18_WordArrayB

y 26F5 2040h

y 273D 3B40h

y 2755 0040h

y 2779 2E2Ch

y 27A3 2E2Ch

y 27CD 2E2Ch

y 27F7 2E2Ch

! 299d RST18_WordArrayB

y 29DC 0003h
y 29E2 0304h
y 29ED 0304h

! 2A25 RST08_FillBbytes

y 2A27 0304h
y 2A33 0304h

# 2A51 Score table. Values are in BCD.
w 2A51-2A6C
! 2A51 Score of small dot
! 2A53 Score of big dot
! 2A55 Score of first ghost eaten
! 2A57 Score of second ghost eaten
! 2A59 Score of third ghost eaten
! 2A5B Score of fourth ghost eaten
! 2A5D Score of 1st prize (Cherries)
! 2A5F Score of 2nd prize (Strawberry)
! 2A61 Score of 3rd prize (Peach)
! 2A63 Score of 4th prize (Apple)
! 2A65 Score of 5th prize (Grape/Cherimoya)
! 2A67 Score of 6th prize (Galaxian)
! 2A69 Score of 7th prize (Bell)
! 2A6B Score of 8th prize (Key)

y 2AC0 001Fh

y 2ACB 0020h

y 2B15 0020h

# 2B61 This looks like dead code, all the way to X2bb4.

# 2B98 This is a JP opcode that goes to a place that doesn't make sense.
# 2B98 Maybe this is never executed? Originally: JP X2bfd
b 2B98-2B9A
l 2BB4 X2bb4

! 2BB8 RST18_WordArrayB

y 2BD4 0000h

p 2BFF ; X2bfd corresponds to a CALL Z,0FD42h, which doesn't make sense
p 2BFF X2bfd	EQU	$-2

y 2BC3 -0400h

y 2BC8 -0001h

y 2BCF -0020h

! 2C5F RST18_WordArrayB

! 2C80 RST20_JumpTable
a 2C81-2CA0

! 2CAD ByteArrayA

! 2CB7 ByteArrayA

y 2D1A 0008h

# 2E28 Clears screen except a vertical strip at position 0
l 2E28 PartialClear

! 2E31 RST08_FillBbytes

b 2E41-37ff
a 31ED-31F0
w 31F1-31F2
a 31F3-321C
w 321D-3222
a 3223-3232
w 3233-3249
a 324B-325A
t 325D-33D9
b 326B
b 32B3
b 3337
b 3345
b 3352
b 335F
b 336C
b 337A
b 3388
t 3435-34AD
# 3542
# 3542 Strided table with fruit/colour
l 3542 FruitCodes
! 3543 Cherry
! 3545 Strawberry
! 3547 1st Peach
! 3549 2nd Peach
! 354B 1st Apple
! 354D 2nd Apple
! 354F 1st Grape/Cherimoya
! 3551 2nd Grape/Cherimoya
! 3553 1st Galaxian
! 3555 2nd Galaxian
! 3557 1st Bell
! 3559 2nd Bell
! 355B 1st Key
! 355D 2nd Key
! 355F 3rd Key
! 3561 4th Key
! 3563 5th Key
! 3565 6th Key
! 3567 7th Key
! 3569 8th Key
l 370E BlankZone

; Added this as a reminder for myself.

;
; DZ80.CTL - Control File for DZ80
;
;   Control codes allowed in the CTL file:
;
;  A - Address          Specifies that the word entry is the address of
;                       something for which a label should be generated.
;
;  B - Byte binary      Eight bit binary data (db).
;
;  C - Code             Executable code that must be analyzed.
;
;  I - Ignore           Treat as uninitialized space. Will not be dis-
;                       assembled as anything unless some other valid
;                       code reaches it.
;
;  L - Label            Generate a label for this address.
;
;  N - No label         Suppress label generation for an address.
;
;  O - Offset           Specify offset to add to addresses.
;
;  P - Patch            Add inline code (macro, for example)
;
;  S - Symbol           Generate a symbol for this value.
;
;  T - Text             ASCII text (db).
;
;  W - Word binary      Sixteen bit binary data (dw).
;
;  X - Operand name     Specify special name for operand.
;
;  Y - Operand name     Specify special name for operand, suppress EQU generatio
;
;  # - Comment          Add header comment to output file.
;
;  ! - Inline comment   Add comment to end of line.
;
;  The difference between labels and symbols is that a label refers
;  to a referenced address, whereas a symbol may be used for 8 or 16
;  bit immediate data. For some opcodes (eg: ld a,xx) only the symbol
;  table will be searched. Other opcodes (eg: ld hl,xx) will search
;  the label table first and then search the symbol table only if the
;  value is not found in the label table.
